<template>
  <div :class="bannerobj.classname" @click="openlink(linkname)">
      <img v-if="!ismobile" :src="url" class="url" />
      <img  v-else :src="thumbnailUrl" class="thumbnailUrl" />
      <span v-if="bannerobj.ismoreshow" class="more">
        <img src="../assets/img/more.png" />
      </span>
    </div>
</template>
<script>
export default {
  name: "Header",
  props:{
    bannerobj: {
      type: Object,
      default() {
        return {};
      },
    },
    ismobile: {
      type: Boolean,
      default:false
    },
  },
  data(){
    return{
      url:'',
      thumbnailUrl:'',
      linkname:''
    }
  },
  created(){
    this.getdata(this.bannerobj.type)
  },
  methods:{
    link(name){
      this.$router.push({path:name})
    },
    openlink(name){
      if(name) window.open(name, '_blank');
    },
    getdata(type){
      bannerApiqueryOne({type:type}).then(res=>{
        this.url = res.data[0].url
        this.thumbnailUrl = res.data[0].thumbnailUrl
        if(res.data[0].no){
          this.linkname = res.data[0].no
        }
      })
    }
  }
};
</script>